Skip to content

fix: replace sync file read with async fs/promises and add error handling#322

Merged
codeZe-us merged 2 commits into
Toolbox-Lab:mainfrom
comzzy-comzzy:fix/async-toml-file-reading
Jul 16, 2026
Merged

fix: replace sync file read with async fs/promises and add error handling#322
codeZe-us merged 2 commits into
Toolbox-Lab:mainfrom
comzzy-comzzy:fix/async-toml-file-reading

Conversation

@comzzy-comzzy

Copy link
Copy Markdown
Contributor

Summary

Fixes #307 — Script crashes or hangs when reading the core TOML taxonomy file unsafely.

Changes

  • Replaced the dummy index.js with a full async implementation using fs/promises
  • Reads crates/core/src/taxonomy/data/contract.toml asynchronously (non-blocking)
  • Explicitly specifies utf-8 encoding to prevent raw Buffer returns
  • Added targeted try/catch with handling for specific Node.js error codes:
    • ENOENT — file not found: outputs actionable message about initializing the crates/core submodule
    • EACCES — permission denied: warns about file permission boundaries
    • EBUSY / EPERM — file locked or operation not permitted
    • Generic fallback for unexpected errors
  • Parses the TOML content using @iarna/toml and outputs the taxonomy as formatted JSON
  • All error messages are clean CLI-friendly diagnostics, no raw V8 stack traces

Testing

  • Verified the script runs without blocking the event loop
  • Tested ENOENT scenario (missing file) — outputs contextual guidance
  • Tested EACCES scenario (restricted permissions) — outputs permission warning
  • Tested happy path — successfully reads and parses the TOML taxonomy

Closes #307

…ling

Resolves Toolbox-Lab#307

- Replace dummy implementation with robust async TOML file reader
- Use fs/promises for non-blocking file I/O with utf-8 encoding
- Add targeted try/catch handling for ENOENT, EACCES, and EISDIR errors
- Output actionable CLI diagnostic messages instead of raw stack traces
- Parse TOML content using @iarna/toml and output as formatted JSON
@codeZe-us
codeZe-us self-requested a review July 16, 2026 22:33
@codeZe-us

Copy link
Copy Markdown
Contributor

@comzzy-comzzy resolve conflicts

…-reading

# Conflicts:
#	examples/core-integration/fetch-taxonomy/index.js
@comzzy-comzzy

comzzy-comzzy commented Jul 16, 2026 via email

Copy link
Copy Markdown
Contributor Author

@codeZe-us

Copy link
Copy Markdown
Contributor

Done ✅️

On Thu, 16 Jul 2026, 23:39 Lewechi, @.> wrote: codeZe-us left a comment (Toolbox-Lab/Grat#322) <#322 (comment)> @comzzy-comzzy https://github.com/comzzy-comzzy resolve conflicts — Reply to this email directly, view it on GitHub <#322?email_source=notifications&email_token=AM5I4FCYBCEIH3OE6MU3DA35FFKRDA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOJZG4ZDOMRSGU42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4997272259>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM5I4FFOMOFGIKGVNFJCVZD5FFKRDAVCNFSNUABGKJSXA33TNF2G64TZHMYTCOBTG42TEMRZGQ5US43TOVSTWNBZGAZTCNJWGQ4DNILWAI . You are receiving this because you were mentioned.Message ID: @.>

Ok

@codeZe-us
codeZe-us merged commit 0414219 into Toolbox-Lab:main Jul 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Script Crashes or Hangs When Reading the Core TOML Taxonomy File Unsafely

2 participants